class UserMailer < ActionMailer::Base
  helper :application
	include RouteTools
	
  def signup_notification(user)
    setup_email(user)
    @subject    += 'активация аккаунта'
    @body[:activate_url]  = "#{RouteTools::URL}/activate/#{user.activation_code}"
  end
  
  def activation(user)
    setup_email(user)
    @subject    += 'аккаунт активорован'
  end
  
  def recover_password(user)
    setup_email(user)
    @subject     += "Recover password"
    @content_type =	"text/html"
    @body[:recover_url] = recover_user_url(:id=>user.recover_code)
  end
  
  protected
    def setup_email(user)
      @recipients  = "#{user.email}"
      @from        = "noreplay@brainberry.ua"
      @subject     = "[Questionnaire] "
      @sent_on     = Time.now
      @body[:user] = user
      @body[:url]  = RouteTools::URL
    end
end
